/**
* Copyright (c) 2015 UNI-TREND Co., Ltd.
* All rights reserved.  
*  
* @file        EffiCal.h
* @brief      cal efficiency of any process
* @version     1.0 
* @author      
* @Email       
* @date        2015-11-19
*/
#pragma once
#include <time.h> 
#include <string>
#include <map>
using namespace std;

typedef time_t COST_TYPE;//Timer_jiffies
/**
*   @brief: CEffiCal. 
*   HOW2USE: create a object in the head of the process u want to measure. 
*                         After it goes out, the times will be record in in-constribute func.
*   @author:
*   @note: create on 2015-11-19
*   @note: 
*/
//template<class COST_TYPE = double>
class CEffiCal
{
public://private:
    CEffiCal(char* pFlag);
    CEffiCal(string flag);    
    ~CEffiCal();    
    COST_TYPE GetTime()
    {
        return clock();
    }
    
private:
    typedef multimap<string, COST_TYPE>            EFFI_RECORD_TYPE;
    typedef multimap<string, COST_TYPE>::iterator  EFFI_RECORD_IT_TYPE;
    typedef pair<string, COST_TYPE>                EFFI_RECORD_INSERT_TYPE;
    static EFFI_RECORD_TYPE s_m_effi_record;
    string m_flag;/** test for log*/
    COST_TYPE m_record;
public:
    string GetFlagByIndex(int index);
    COST_TYPE GetCostByIndex(int index);
    COST_TYPE GetCostByFlag(char* pFlag){return 0;};
    COST_TYPE GetCostByFlag(string flag){return 0;};
    /**
            * Output2Log, is to output all efficiency info to log buff. 
            * It should be manually called.
            */
    static void Output2Log();
};

